package suites.tween {
	import org.flexunit.asserts.assertEquals;
	import org.splink.library.queue.QEvent;
	import org.splink.library.tween.QTweenConst;

	/**
	 * @author Max Kugland
	 */
	public class TweenBasicTest extends AbstractTweenTest {
		
		[Test(async)]
		public function testEmty() :void {
			handleAsync(50);
			_tween.start();
		}

		[Test(async)]
		public function testSingle() : void {
			handleAsync(500);
			_tween.add(QTweenConst.ALPHA, 1, 0).duration(400);
			_tween.register(QEvent.COMPLETE, function(e : QEvent):void {
				assertEquals(1, _target.alpha);
			});
			_tween.start();
			assertEquals(0, _target.alpha);
		}

		[Test(async)]
		public function testSingleDelay() : void {
			handleAsync(700);
			_tween.add(QTweenConst.ALPHA, 1, 0).duration(400).delay(200);
			_tween.register(QEvent.COMPLETE, function(e : QEvent):void {
				assertEquals(1, _target.alpha);
			});
			_tween.start();
			assertEquals(0, _target.alpha);
		}

		[Test(async)]
		public function testZeroDuration() : void {
			handleAsync(50);
			_tween.add(QTweenConst.ALPHA, 1, 0).duration(0);
			_tween.register(QEvent.COMPLETE, function(e : QEvent):void {
				assertEquals(1, _target.alpha);
			});
			_tween.start();
			assertEquals(0, _target.alpha);
		}

		[Test(async)]
		public function testZeroDurationDelay() : void {
			handleAsync(250);
			_tween.add(QTweenConst.ALPHA, 1, 0).duration(0).delay(200);
			_tween.register(QEvent.COMPLETE, function(e : QEvent):void {
				assertEquals(1, _target.alpha);
			});
			_tween.start();
			assertEquals(0, _target.alpha);
		}

		[Test(async)]
		public function testMulti() : void {
			handleAsync(500);
			_tween.add(QTweenConst.ALPHA, 1, 0).add(QTweenConst.X, 100).add(QTweenConst.Y, 100).duration(400);
			_tween.register(QEvent.COMPLETE, function(e : QEvent):void {
				assertEquals(1, _target.alpha);				assertEquals(100, _target.x);				assertEquals(100, _target.y);
			});
			_tween.start();
			assertEquals(0, _target.alpha);			assertEquals(0, _target.x);			assertEquals(0, _target.y);
		}
		
		[Test(async)]
		public function testMultiDelay() : void {
			handleAsync(700);
			_tween.add(QTweenConst.ALPHA, 1, 0).add(QTweenConst.X, 100).add(QTweenConst.Y, 100).duration(400).delay(200);
			_tween.register(QEvent.COMPLETE, function(e : QEvent):void {
				assertEquals(1, _target.alpha);
				assertEquals(100, _target.x);
				assertEquals(100, _target.y);
			});
			_tween.start();
			assertEquals(0, _target.alpha);
			assertEquals(0, _target.x);
			assertEquals(0, _target.y);
		}
	}
}
